<?
 	session_start();
 	require("connect.php");
 	$chon = $_REQUEST["option"];
	if ($_REQUEST["option"]==Xoa)
	mysql_query("delete from thongbaolop where matb='{$_REQUEST["matb"]}'");	
?>
<html><!-- InstanceBegin template="/Templates/lopctntemplate.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language="Javascript" src="scripts/innovaeditor.js"></script>
<link rel="stylesheet" type="text/css" href="css/engine.css" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script language="javascript" type="text/javascript" src="js/datetimepicker.js">
</script>
</head>
<body>
<table align="center" width="938" cellpadding="0" cellspacing="0" border="0">
	<tr><td colspan="3" height="26" bgcolor="#CCCCCC">		
	<? $malop=$_REQUEST["mal"];
		$resu99=mysql_query("select * from lop where mal='{$malop}'");
		$row99=mysql_fetch_array($resu99);
	?>	
	<!--Menu 1-->
	<div id="tool">

	<a href="index.php">Trang chủ trường</a>
		 | 
		 <a href="hotrohoctap.php">Hỗ trợ học tập</a>
		 |				 
		<a href="lienhe.php">Liên hệ</a>
	</div>
	<!--het menu 1-->
	</td></tr>
	<tr><td colspan="3" height="34" bgcolor="#CCCCCC">	
	<div id="menuwrapper">
		<ul id="p7menubar">
			 <li><a class="trigger" href="lopcuatoi.php?mal=<? echo $malop;?>" target="_self">Trang chủ lớp <? echo $row99["tenl"];?></a></li>										  	
		  <li class="linemenus"></li>					 
		  <li>
		  <?
		  	if ($_SESSION["login"]!=true){
		  ?>		  
		  <a class="trigger" href="login.php" target="_self">Trang cá nhân</a>
		  <? } else {
		  		if($_SESSION["quyen"]==0) {
		  ?>	
		   			<a class="trigger" href="admin/index.php" target="_self">Trang cá nhân</a>
		  		<? } else if($_SESSION["quyen"]==1) {?>
					<a class="trigger" href="giaovien.php?magv=<? echo $_SESSION["username"];?>" target="_self">Trang cá nhân</a>
				<? } else if($_SESSION["quyen"]==2) {?>
					<a class="trigger" href="trangphuhuynh.php?maph=<? echo $_SESSION["username"];?>&mal=<? echo $malop;?>" target="_self">Trang cá nhân</a>
				<? } else if(($_SESSION["quyen"]==3) || ($_SESSION["quyen"]==4)) {?>
					<a class="trigger" href="tranghocsinh.php?mahs=<? echo $_SESSION["username"];?>&mal=<? echo $malop;?>" target="_self">Trang cá nhân</a>
				<? }?>
		  		
		  <? }?>
		  <!--bat dau phan dang nhap-->
		  <?
				if ($_SESSION["login"]!=true){
			?>
			 <li class="linemenus"></li>					 
		  	 <li><a class="trigger" href="login.php" target="_self">Đăng nhập</a>			
			<? }else{?>
			 <li class="linemenus"></li>					 
		  	 <li><a class="trigger" href="logout.php" target="_self">Thoát</a>			
			 <li class="linemenus"></li>
			 <li><a class="trigger">
			 	<?
		$nguoidung=$_SESSION["username"];
		if($_SESSION["quyen"]==0){
		$resu23=mysql_query("select * from admin where maadmin='{$nguoidung}'");
		$row23=mysql_fetch_array($resu23);
		?>
			<font color="#FFFFFF">			 
			<? echo "Xin chào : ".$row23["hotendem"]."&nbsp;".$row23["ten"]; ?>
			</font>
		<? }else if($_SESSION["quyen"]==1){
			$resu23=mysql_query("select * from giaovien where magv='{$nguoidung}'");
			$row23=mysql_fetch_array($resu23);
		?>
			<font color="#FFFFFF">			 
			<? echo "Xin chào : ".$row23["hotendem"]."&nbsp;".$row23["ten"]; ?>
			</font>
		<? }else if($_SESSION["quyen"]==2){
			$resu23=mysql_query("select * from phuhuynh where maph='{$nguoidung}'");
			$row23=mysql_fetch_array($resu23);
		?>
			<font color="#FFFFFF">			 
			<? echo "Xin chào : ".$row23["tenph"]; ?>
			</font>
		<? }else if(($_SESSION["quyen"]==3)||($_SESSION["quyen"]==4)){
				$resu23=mysql_query("select * from hocsinh where mahs='{$nguoidung}'");
				$row23=mysql_fetch_array($resu23);
		?>
			<font color="#FFFFFF">			 
			<? echo "Xin chào : ".$row23["hotendem"]."&nbsp;".$row23["ten"]; ?>
			</font>
		<? }
	}?>
		  <!--het-->		 
		</ul>
	</div>	
	</td></tr>
	<tr>
		<td width="160px" height="800" valign="top">		
		<!--menu trai-->
		<table align="center" width="100%" border="1" cellpadding="0" cellspacing="0">
		<tr><td valign="middle" height="30">
			<a href="sodaubai.php?mal=<? echo $malop;?>"><img src="anh/sodaubai.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="sodaubai.php?mal=<? echo $malop;?>">Sổ đầu bài</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="danhsachhocsinh.php?mal=<? echo $malop;?>"><img src="anh/user.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="danhsachhocsinh.php?mal=<? echo $malop;?>">Danh sách học sinh</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="thuvienanhlop.php?mal=<? echo $malop;?>.php"><img src="anh/album.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="thuvienanhlop.php?mal=<? echo $malop;?>">Thư viện ảnh</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="lopcuatoi_baiviet.php?mal=<? echo $malop;?>"><img src="anh/baiviet.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="lopcuatoi_baiviet.php?mal=<? echo $malop;?>">Bài viết</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="thoikhoabieu.php?mal=<? echo $malop;?>"><img src="anh/thoikhoabieu.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="thoikhoabieu.php?mal=<? echo $malop;?>">Thời khóa biểu</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="thongbaolop.php?mal=<? echo $malop;?>"><img src="anh/thongbao.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="thongbaolop.php?mal=<? echo $malop;?>">Thông báo</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="tailieulop.php?mal=<? echo $malop;?>""><img src="anh/tailieu.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="tailieulop.php?mal=<? echo $malop;?>">Tài liệu Upload</a>
		</td></tr>
		<tr><td valign="middle" height="30">
			<a href="xemdiemlop.php?mal=<? echo $malop;?>""><img src="anh/xemdiem.png" height="16" width="16" border="0">&nbsp;&nbsp;</a><a href="xemdiemlop.php?mal=<? echo $malop;?>">Xem điểm</a>
		</td></tr>				
		</table>
		<!-- het menu trai-->
		</td>
		
    <td align="center" valign="top"><!-- InstanceBeginEditable name="EditRegion3" -->
	<table align="center" cellpadding="1" cellspacing="1" border="0" width="99%">
	<?		
		$mal=$_REQUEST["mal"];
	?>
	<tr>	
	<td align="center">				
				<!--Begin-->
				<div class="gift_box_quatang">
					<div class="gift_quatang_topblog">
						<p class="gift_quatang_fl_left"><img src="anh/space.gif"></p>
						<p class="gift_quatang_fl_right"><img src="anh/space.gif"></p>
					</div>
					<div class="gift_quatang_infoblog">
						<h1 align="left"><font color="#CC3333">Bài viết mới</font></h1>
						<table align="center" cellpadding="0" cellspacing="3" border="0" width="100%">
						<?							
							$result1=mysql_query("select * from baiviet where mal='{$mal}' and trangthai='1' order by ngay DESC limit 0,4");
							while($r1=mysql_fetch_array($result1)){
						?><tr><td colspan="2">							
							<a href="baiviet_detail.php?mabv=<? echo $r1["mabv"];?>&mal=<? echo $mal;?>">
								<img src="anh/icon1.gif" width="16" height="16" border="0">&nbsp;
								<? echo $r1["tieude"];?>
							</a>
							</td></tr>							
							<tr>
								<td colspan="2">
									<?										
										$string=$r1["noidung"];
										echo substr($string,0,100);
										if(strlen($string)>=101){
										echo "...";						
										}				
									?>
								</td>
							</tr>
							<tr>
								<td class="tieude3">  bởi 
							<?
								$result=mysql_query("select * from hocsinh where mahs='{$r1["nguoidang"]}'");
								if(mysql_num_rows($result)>0){
								while($r=mysql_fetch_array($result)){
									echo $r["hotendem"];
									echo "&nbsp;";
									echo $r["ten"];
								}}else {
									$result2=mysql_query("select * from giaovien where magv='{$r1["nguoidang"]}'"); 
									$r2=mysql_fetch_array($result2);									
									echo $r2["hotendem"];
									echo "&nbsp;";
									echo $r2["ten"];
								}
							?>								
								&nbsp;vào lúc &nbsp;<? echo $r1["ngay"];?>
								</td>
								<td class="tieude4"></td>
							</tr>
							<tr><td colspan="2" class="tieude3">thuộc <?
							$result3=mysql_query("select * from loaibaiviet where malbv='{$r1["malbv"]}'");
							$r3=mysql_fetch_array($result3);
							?>
							<a href="loaibaiviet.php?malbv=<? echo $r1["malbv"];?>&mal=<? echo $mal;?>"><?
							echo $r3["tenlbv"];
							?></a>
							</td></tr>
							<tr><td colspan="2"></td></tr>
						<?
							}
						?>		
						</table>			 
						<div class="gift_quatang_mView">
							<span style="float:left; width:90px;"> 
							<a href="lopcuatoi_baiviet.php?mal=<? echo $mal;?>" title="Xem tất cả bài viết">
							<img src="anh/dlet_artblock_point_1.gif" width="13" height="9" border="0" />
							Xem thêm</a></span>
							<span style=" float: right; width:100px" >
								<?
								if($_SESSION["quyen"]==1)
								{
									$magv=$_SESSION["username"];
									$result22=mysql_query("select * from lop where mal='{$mal}'");
									$r22=mysql_fetch_array($result22);
									if($magv==$r22["magvcn"]){
								?>
											<a href="vietbai.php?mal=<? echo $mal;?>" title="Viết bài mới">
												<img src="anh/them.png" height="13" width="13" border="0">&nbsp;Viết bài mới
											</a>
									<? } else {
											$result23=mysql_query("select * from thoikhoabieu where magv='{$magv}' and mal='{$mal}'");
											if(mysql_num_rows($result23)>0)
											{?>
												<a href="vietbai.php?mal=<? echo $mal;?>" title="Viết bài mới">
												<img src="anh/them.png" height="13" width="13" border="0">&nbsp;Viết bài mới
											</a>
											<? }
									?>
											
									<? }?>
								<?
								}else if(($_SESSION["quyen"]==3)||($_SESSION["quyen"]==4))
								{
									$mahs=$_SESSION["username"];
									$result4=mysql_query("select * from hocsinh where mahs='{$mahs}'");
									$r4=mysql_fetch_array($result4);
									if($mal==$r4["mal"])
									{
										?>
										<a href="vietbai.php?mal=<? echo $mal;?>" title="Viết bài mới">
										<img src="anh/them.png" height="13" width="13" border="0">&nbsp;Viết bài mới
										</a>
										<?
									}
								}
								?>
			
							</span>
						</div>
					</div>
					<div class="gift_quatang_btmblog">
						<p class="gift_quatang_bl_left"><img src="anh/space.gif"></p>
						<p class="gift_quatang_bl_right"><img src="anh/space.gif"></p>
					</div>
			
				</div>
				<!--End-->
				
	<!--Begin thu vien anh-->
	<div class="gift_box_quatang">
		<div class="gift_quatang_topblog">
			<p class="gift_quatang_fl_left"><img src="anh/space.gif"></p>
			<p class="gift_quatang_fl_right"><img src="anh/space.gif"></p>
		</div>
		<div class="gift_quatang_infoblog">
			<h1 align="left"><font color="#CC3333">Ảnh nổi bật</font></h1>
				<table align="center" cellpadding="0" cellspacing="3" border="0" width="99%">
						<?							
							$result6=mysql_query("select DISTINCT maalbum from thuvienanhlop where mal='{$mal}' and trangthai='1' order by thoigian DESC limit 0,8");								
											$j=0;
											while($r6=mysql_fetch_array($result6)){
												if($j==0) echo "<tr>";
												{
												$result7=mysql_query("select * from thuvienanhlop where maalbum='{$r6["maalbum"]}' limit 0,1");												
											?>
													<td align="center">
														<table align="center" border="0" cellpadding="0" cellspacing="3" width="116px">
															<tr><td align="center">
															<? 
															while($r7=mysql_fetch_array($result7)) {;
															?>
															<div style=" border:1px solid #EEEEEE; padding:5px;">
																<a href="chitietalbumlop.php?maalbum=<? echo $r7["maalbum"];?>&mal=<? echo $mal;?>" title="<? echo $r7["tenanh"];?>">
																<img src="thumb.php?h=116&w=116&url=thuvienanh/<? echo $r7["duongdan"];?>" border="0"/>
																</a>
															</div>
															<? } //end cua r7?>
															</td></tr>
														</table>
													</td>
											<?													
													$j++;
												} //end cua if(j=0)
										
												if ((($j)%4)==0)
												{ 
													echo "</tr>";									
												}
											} //end cua while6																
							?>		
						</table>							 
			<div class="gift_quatang_mView">
				<span style="float:left; width:90px;"> 
					<a href="thuvienanh.php?mal=<? echo $mal;?>">
					<img src="anh/dlet_artblock_point_1.gif" width="13" height="9" border="0" />
					Xem thêm</a>
				</span>
				<span style=" float: right; width:100px">
							<?
								if($_SESSION["quyen"]==1)
								{
									$magv=$_SESSION["username"];
									$result22=mysql_query("select * from lop where mal='{$mal}'");
									$r22=mysql_fetch_array($result22);
									if($magv==$r22["magvcn"]){
								?>
											<a href="danganh.php?mal=<? echo $mal;?>" title="Đăng ảnh mới">
												<img src="anh/them.png" height="13" width="13" border="0">&nbsp;Đăng ảnh
											</a>
									<? } else {
											$result23=mysql_query("select * from thoikhoabieu where magv='{$magv}' and mal='{$mal}'");
											if(mysql_num_rows($result23)>0)
											{?>
												<a href="danganh.php?mal=<? echo $mal;?>" title="Đăng ảnh mới">
												<img src="anh/them.png" height="13" width="13" border="0">&nbsp;Đăng ảnh
											</a>
											<? }
									?>
											
									<? }?>
								<?
								}else if(($_SESSION["quyen"]==3)||($_SESSION["quyen"]==4))
								{
									$mahs=$_SESSION["username"];
									$result4=mysql_query("select * from hocsinh where mahs='{$mahs}'");
									$r4=mysql_fetch_array($result4);
									if($mal==$r4["mal"])
									{
										?>
										<a href="danganh.php?mal=<? echo $mal;?>" title="Đăng ảnh mới">
												<img src="anh/them.png" height="13" width="13" border="0">&nbsp;Đăng ảnh
											</a>
										<?
									}
								}
								?>
				  </span>
			</div>
		</div>
		<div class="gift_quatang_btmblog">
			<p class="gift_quatang_bl_left"><img src="anh/space.gif"></p>
			<p class="gift_quatang_bl_right"><img src="anh/space.gif"></p>
		</div>

	</div>
	<!--End-->
	<!--Begin thong bao moi-->
	<div class="gift_box_quatang">
		<div class="gift_quatang_topblog">
			<p class="gift_quatang_fl_left"><img src="anh/space.gif"></p>
			<p class="gift_quatang_fl_right"><img src="anh/space.gif"></p>
		</div>
		<div class="gift_quatang_infoblog">
			<h1 align="left"><font color="#CC3333">Thông báo mới</font></h1>
			<table align="center" cellpadding="0" cellspacing="3" width="100%">
				<?
				$result4=mysql_query("select * from thongbaolop where mal='{$mal}' and trangthai='1' order by ngay limit 0,5");
				if(mysql_num_rows($result4)<=0)
				{
					echo "Không có thông báo của lớp trong cơ sở dữ liệu !";
				} else {
				while($r4=mysql_fetch_array($result4)){
				$result5=mysql_query("select * from nguoidung where username='{$r4["nguoidang"]}'");	
				$r5=mysql_fetch_array($result5);
				if($r5["quyen"]==1)
					{
						$result6=mysql_query("select * from giaovien where magv='{$r4["nguoidang"]}'");
						$r6=mysql_fetch_array($result6);
						$nguoidang=$r6["hotendem"]."&nbsp;".$r6["ten"];
						$anh="anhgiaovien/".$r6["anh"];
					} else {
						$result7=mysql_query("select * from hocsinh where mahs='{$r4["nguoidang"]}'");
						$r7=mysql_fetch_array($result7);
						$nguoidang=$r7["hotendem"]."&nbsp;".$r7["ten"];
						$anh="anhhocsinh/".$r7["anh"];
					}			
				?>		
				<tr>
				<td>					
							<!--noi dung-->
							<table align="center" cellspacing="3" cellpadding="0" border="0" width="99%">
							<tr>
								<td rowspan="3" valign="top" width="65px">
								<div class="tieudiem" style="width:65px; height:60px; text-align:center">
									<div style=" border:1px solid #EEEEEE; padding:5px;">
									<img src="thumb.php?h=55&w=60&url=<? echo $anh;?>"/>
									</div>
								</div>
								</td>
								<td class="tieude1" align="left" height="11px" valign="top">								
								Người đăng : <? echo $nguoidang;?>
								</td>
							</tr>
							<tr><td valign="top">Nội dung</td></tr>
							<tr><td>
								<? echo $r4["noidung"];?>
							</td></tr>	
							<tr>
								<td></td>
								<td align="left">Vào ngày <? echo $r4["ngay"];?>
								&nbsp;&nbsp;&nbsp;
								<?
								if($_SESSION["username"]==$r4["nguoidang"])
								{
								?>
									<a href="suathongbaolop.php?matb=<? echo $r4["matb"];?>&mal=<? echo $mal;?>" title="Sửa thông báo">
									<img src="anh/sua.png" height="13" width="13" border="0">&nbsp;Sửa
									</a>&nbsp;
									<a href="?matb=<? echo $r4["matb"];?>&option=Xoa&mal=<? echo $mal;?>" title="Xóa thông báo" onClick="return confirm('Bạn có chắc muốn xóa không ?');">									
									<img src="anh/xoa.png" height="13" width="13" border="0">&nbsp;Xóa
									</a>
								<?
								} ?>
								</td>
                     			
							</tr>																											
					</table>							
							<!--end noi dung-->							
				</td>
				</tr>			 
				<? }}?>				
			</table>
			<div class="gift_quatang_mView">
				<span style="float:left; width:90px;">
					<a href="thongbaolop.php?mal=<? echo $mal;?>">
						<img src="anh/dlet_artblock_point_1.gif" width="13" height="9" border="0" />
					Xem thêm</a>
				 </span>
				<span style=" float: right;">								   
					 <?
								if($_SESSION["quyen"]==1)
								{
									$magv=$_SESSION["username"];
									$result22=mysql_query("select * from lop where mal='{$mal}'");
									$r22=mysql_fetch_array($result22);
									if($magv==$r22["magvcn"]){
								?>
											<a href="themthongbaolop.php?mal=<? echo $mal;?>" title="Đăng thông báo">
												<img src="anh/them.png" height="13" width="13" border="0">&nbsp;Đăng thông báo
											</a>
									<? } else {
											$result23=mysql_query("select * from thoikhoabieu where magv='{$magv}' and mal='{$mal}'");
											if(mysql_num_rows($result23)>0)
											{?>
												<a href="themthongbaolop.php?mal=<? echo $mal;?>" title="Đăng thông báo">
												<img src="anh/them.png" height="13" width="13" border="0">&nbsp;Đăng thông báo
											</a>
											<? }																				
									}
								}else if($_SESSION["quyen"]==4)
								{
									$mahs=$_SESSION["username"];
									$result4=mysql_query("select * from hocsinh where mahs='{$mahs}'");
									$r4=mysql_fetch_array($result4);
									if($mal==$r4["mal"])
									{
										?>
										<a href="themthongbaolop.php?mal=<? echo $mal;?>" title="Đăng thông báo">
										<img src="anh/them.png" height="13" width="13" border="0">&nbsp;Đăng thông báo
										</a>
										<?
									}
								}
								?>
				  </span>
			</div>
		</div>
		<div class="gift_quatang_btmblog">
			<p class="gift_quatang_bl_left"><img src="anh/space.gif"></p>
			<p class="gift_quatang_bl_right"><img src="anh/space.gif"></p>
		</div>

	</div>
	<!--End-->
	</td></tr>
	</table>
	<!-- InstanceEndEditable --></td>
	<!--menu phai-->
	<td width="190" valign="top" align="center">
		<div class="panel">
			<div class="panel_header">Thành viên lớp</div>
			<table align="center" width="100%" cellpadding="1" cellpadding="1" border="0">
			<tr>
			<?
				$resu4=mysql_query("select * from hocsinh where mal='{$malop}' ORDER BY RAND() LIMIT 12");
				$j=0;
				while($row4=mysql_fetch_array($resu4)){
					$j++;					
			?>
				<td>
				<div style=" border:1px solid #EEEEEE; padding:2px;">
				<a href="tranghocsinh.php?mahs=<? echo $row4["mahs"];?>&mal=<? echo $malop;?>" title="<? echo $row4["hotendem"]."&nbsp;".$row4["ten"];?>">
					<img src="thumb.php?h=41&w=41&url=anhhocsinh/<? echo $row4["anh"];?>" border="0"/>
				</a>
				</div>
				</td>
				<? if($j==4){?>			
			</tr><tr>
				<? 
				$j=0;
				}?>
			<? }?>
			</table>
		</div>
		<!--anh phai-->
		<div class="panel">
			<div class="panel_header">Album ảnh</div>
			<marquee height="300" width="100%" onmouseout="this.start()" onmouseover="this.stop()" scrolldelay="2" scrollamount="2" direction="up" behavior="scroll">
				<table align="center" width="99%" cellpadding="2" cellspacing="0" border="0" bgcolor="#FFFFFF">					
					<?
					$resu23=mysql_query("select * from thuvienanhlop where trangthai=1");
					while($row23=mysql_fetch_array($resu23)){
					?>
						<tr><td>
						<div style=" border:1px solid #EEEEEE; padding:4px;">
							<a href='chitietthuvienanh.php?maalbum=<? echo $row23["maalbum"];?>'>
								<img src="thumb.php?h=170&w=180&url=thuvienanh/<? echo $row23["duongdan"];?>" border="0"/>							
							</a>
						</div>
						</td>
						</tr>
					<? }?>     					
				</table>
			</marquee>	
		</div>
		<!--het anh phai-->
	</td>
	</tr>
	<tr><td colspan="3" align="center" valign="middle" bgcolor="#999999" height="100">Phạm Đức Đóa - Khoa CNTT - Đại học Xây Dựng</td></tr>
</table>
</body>
<!-- InstanceEnd --></html>
